package override;

class LoveContryMan{
	public void protectCountry() {
		System.out.println("爱国者守护国家");
	}
}
class Soldier extends LoveContryMan{
	public void protectCountry() {
		System.out.println("代表国家消灭敌人");
	}
}
class Student extends LoveContryMan{
	public void protectCountry() {
		System.out.println("为中华之崛起而读书");
	}
}
class RedMan extends LoveContryMan{
	public void protectCountry() {
		System.out.println("防止网络攻击和网暴");
	}
}
public class Demo2 {
	public static void main(String[] args) {
		// 一个父类引用，根据指向了不同的子类对象，调用子类重写的方法，实现了多态
		LoveContryMan man = new Soldier();
		man.protectCountry();
		man = new Student();
		man.protectCountry();
		man = new RedMan();
		man.protectCountry();
	}
}
